<?php
/**
 * TargetingClauseEx
 *
 * PHP version 5
 *
 * @category Class
 * @package  AmazonAdvertisingApi
 * @author   vv_guo
 * @link    https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 */

/**
 * Amazon Ads API for Sponsored Display
 *
 * This API enables programmatic access for campaign creation, management, and reporting for Sponsored Display campaigns. For more information on the functionality, see the [Sponsored Display Support Center](https://advertising.amazon.com/help#GTPPHE6RAWC2C4LZ). For API onboarding information, see the [account setup](https://advertising.amazon.com/API/docs/en-us/guides/onboarding/overview) topic.<br/><br/> > This specification is available for download from the **[Advertising API developer portal](https://d3a0d0y2hgofx6.cloudfront.net/openapi/en-us/sponsored-display/3-0/openapi.yaml).**
 *
 * OpenAPI spec version: 3.0
 * 
 * Generated by:https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api.git
 * AmazonAdvertisingApi Codegen version: 3.0.51
 */
/**
 * NOTE: This class is auto generated by the AmazonAdvertisingApi code generator program.
 *https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 * Do not edit the class manually.
 */

namespace AmazonAdvertisingApi\Model;

use \ArrayAccess;
use \AmazonAdvertisingApi\ObjectSerializer;

/**
 * TargetingClauseEx Class Doc Comment
 *
 * @category Class
 * @package  AmazonAdvertisingApi
 * @author   vv_guo
 * @link    https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 */
class TargetingClauseEx implements ModelInterface, ArrayAccess
{
    const DISCRIMINATOR = null;

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static $AmazonAdvertisingApiModelName = 'TargetingClauseEx';

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $AmazonAdvertisingApiTypes = [
        'target_id' => 'float',
        'ad_group_id' => 'float',
        'campaign_id' => 'float',
        'state' => 'string',
        'expression_type' => 'string',
        'bid' => 'float',
        'expression' => '\AmazonAdvertisingApi\Model\TargetingExpression',
        'resolved_expression' => '\AmazonAdvertisingApi\Model\TargetingExpression',
        'serving_status' => 'string',
        'creation_date' => 'int',
        'last_updated_date' => 'int'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $AmazonAdvertisingApiFormats = [
        'target_id' => null,
        'ad_group_id' => null,
        'campaign_id' => null,
        'state' => null,
        'expression_type' => null,
        'bid' => null,
        'expression' => null,
        'resolved_expression' => null,
        'serving_status' => null,
        'creation_date' => 'int64',
        'last_updated_date' => 'int64'
    ];

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function AmazonAdvertisingApiTypes()
    {
        return self::$AmazonAdvertisingApiTypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function AmazonAdvertisingApiFormats()
    {
        return self::$AmazonAdvertisingApiFormats;
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'target_id' => 'targetId',
        'ad_group_id' => 'adGroupId',
        'campaign_id' => 'campaignId',
        'state' => 'state',
        'expression_type' => 'expressionType',
        'bid' => 'bid',
        'expression' => 'expression',
        'resolved_expression' => 'resolvedExpression',
        'serving_status' => 'servingStatus',
        'creation_date' => 'creationDate',
        'last_updated_date' => 'lastUpdatedDate'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'target_id' => 'setTargetId',
        'ad_group_id' => 'setAdGroupId',
        'campaign_id' => 'setCampaignId',
        'state' => 'setState',
        'expression_type' => 'setExpressionType',
        'bid' => 'setBid',
        'expression' => 'setExpression',
        'resolved_expression' => 'setResolvedExpression',
        'serving_status' => 'setServingStatus',
        'creation_date' => 'setCreationDate',
        'last_updated_date' => 'setLastUpdatedDate'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'target_id' => 'getTargetId',
        'ad_group_id' => 'getAdGroupId',
        'campaign_id' => 'getCampaignId',
        'state' => 'getState',
        'expression_type' => 'getExpressionType',
        'bid' => 'getBid',
        'expression' => 'getExpression',
        'resolved_expression' => 'getResolvedExpression',
        'serving_status' => 'getServingStatus',
        'creation_date' => 'getCreationDate',
        'last_updated_date' => 'getLastUpdatedDate'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$AmazonAdvertisingApiModelName;
    }

    const STATE_ENABLED = 'enabled';
    const STATE_PAUSED = 'paused';
    const STATE_ARCHIVED = 'archived';
    const EXPRESSION_TYPE_AUTO = 'auto';
    const EXPRESSION_TYPE_MANUAL = 'manual';
    const SERVING_STATUS_ADVERTISER_STATUS_ENABLED = 'ADVERTISER_STATUS_ENABLED';
    const SERVING_STATUS_STATUS_UNAVAILABLE = 'STATUS_UNAVAILABLE';
    const SERVING_STATUS_ADVERTISER_PAUSED = 'ADVERTISER_PAUSED';
    const SERVING_STATUS_ACCOUNT_OUT_OF_BUDGET = 'ACCOUNT_OUT_OF_BUDGET';
    const SERVING_STATUS_ADVERTISER_PAYMENT_FAILURE = 'ADVERTISER_PAYMENT_FAILURE';
    const SERVING_STATUS_CAMPAIGN_PAUSED = 'CAMPAIGN_PAUSED';
    const SERVING_STATUS_CAMPAIGN_ARCHIVED = 'CAMPAIGN_ARCHIVED';
    const SERVING_STATUS_PENDING_START_DATE = 'PENDING_START_DATE';
    const SERVING_STATUS_ENDED = 'ENDED';
    const SERVING_STATUS_CAMPAIGN_OUT_OF_BUDGET = 'CAMPAIGN_OUT_OF_BUDGET';
    const SERVING_STATUS_AD_GROUP_STATUS_ENABLED = 'AD_GROUP_STATUS_ENABLED';
    const SERVING_STATUS_AD_GROUP_PAUSED = 'AD_GROUP_PAUSED';
    const SERVING_STATUS_AD_GROUP_ARCHIVED = 'AD_GROUP_ARCHIVED';
    const SERVING_STATUS_AD_GROUP_INCOMPLETE = 'AD_GROUP_INCOMPLETE';
    const SERVING_STATUS_AD_GROUP_LOW_BID = 'AD_GROUP_LOW_BID';
    const SERVING_STATUS_TARGET_STATUS_LIVE = 'TARGET_STATUS_LIVE';
    const SERVING_STATUS_TARGET_STATUS_PAUSED = 'TARGET_STATUS_PAUSED';
    const SERVING_STATUS_TARGET_STATUS_ARCHIVED = 'TARGET_STATUS_ARCHIVED';
    const SERVING_STATUS_ADVERTISER_EXCEED_SPENDS_LIMIT = 'ADVERTISER_EXCEED_SPENDS_LIMIT';
    const SERVING_STATUS_AD_POLICING_PENDING_REVIEW = 'AD_POLICING_PENDING_REVIEW';
    const SERVING_STATUS_CAMPAIGN_INCOMPLETE = 'CAMPAIGN_INCOMPLETE';
    const SERVING_STATUS_INELIGIBLE = 'INELIGIBLE';
    const SERVING_STATUS_PORTFOLIO_ENDED = 'PORTFOLIO_ENDED';
    const SERVING_STATUS_PORTFOLIO_OUT_OF_BUDGET = 'PORTFOLIO_OUT_OF_BUDGET';
    const SERVING_STATUS_ADVERTISER_ARCHIVED = 'ADVERTISER_ARCHIVED';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getStateAllowableValues()
    {
        return [
            self::STATE_ENABLED,
            self::STATE_PAUSED,
            self::STATE_ARCHIVED,
        ];
    }
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getExpressionTypeAllowableValues()
    {
        return [
            self::EXPRESSION_TYPE_AUTO,
            self::EXPRESSION_TYPE_MANUAL,
        ];
    }
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getServingStatusAllowableValues()
    {
        return [
            self::SERVING_STATUS_ADVERTISER_STATUS_ENABLED,
            self::SERVING_STATUS_STATUS_UNAVAILABLE,
            self::SERVING_STATUS_ADVERTISER_PAUSED,
            self::SERVING_STATUS_ACCOUNT_OUT_OF_BUDGET,
            self::SERVING_STATUS_ADVERTISER_PAYMENT_FAILURE,
            self::SERVING_STATUS_CAMPAIGN_PAUSED,
            self::SERVING_STATUS_CAMPAIGN_ARCHIVED,
            self::SERVING_STATUS_PENDING_START_DATE,
            self::SERVING_STATUS_ENDED,
            self::SERVING_STATUS_CAMPAIGN_OUT_OF_BUDGET,
            self::SERVING_STATUS_AD_GROUP_STATUS_ENABLED,
            self::SERVING_STATUS_AD_GROUP_PAUSED,
            self::SERVING_STATUS_AD_GROUP_ARCHIVED,
            self::SERVING_STATUS_AD_GROUP_INCOMPLETE,
            self::SERVING_STATUS_AD_GROUP_LOW_BID,
            self::SERVING_STATUS_TARGET_STATUS_LIVE,
            self::SERVING_STATUS_TARGET_STATUS_PAUSED,
            self::SERVING_STATUS_TARGET_STATUS_ARCHIVED,
            self::SERVING_STATUS_ADVERTISER_EXCEED_SPENDS_LIMIT,
            self::SERVING_STATUS_AD_POLICING_PENDING_REVIEW,
            self::SERVING_STATUS_CAMPAIGN_INCOMPLETE,
            self::SERVING_STATUS_INELIGIBLE,
            self::SERVING_STATUS_PORTFOLIO_ENDED,
            self::SERVING_STATUS_PORTFOLIO_OUT_OF_BUDGET,
            self::SERVING_STATUS_ADVERTISER_ARCHIVED,
        ];
    }

    /**
     * Associative array for storing property values
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->container['target_id'] = isset($data['target_id']) ? $data['target_id'] : null;
        $this->container['ad_group_id'] = isset($data['ad_group_id']) ? $data['ad_group_id'] : null;
        $this->container['campaign_id'] = isset($data['campaign_id']) ? $data['campaign_id'] : null;
        $this->container['state'] = isset($data['state']) ? $data['state'] : null;
        $this->container['expression_type'] = isset($data['expression_type']) ? $data['expression_type'] : null;
        $this->container['bid'] = isset($data['bid']) ? $data['bid'] : null;
        $this->container['expression'] = isset($data['expression']) ? $data['expression'] : null;
        $this->container['resolved_expression'] = isset($data['resolved_expression']) ? $data['resolved_expression'] : null;
        $this->container['serving_status'] = isset($data['serving_status']) ? $data['serving_status'] : null;
        $this->container['creation_date'] = isset($data['creation_date']) ? $data['creation_date'] : null;
        $this->container['last_updated_date'] = isset($data['last_updated_date']) ? $data['last_updated_date'] : null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        $allowedValues = $this->getStateAllowableValues();
        if (!is_null($this->container['state']) && !in_array($this->container['state'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'state', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        $allowedValues = $this->getExpressionTypeAllowableValues();
        if (!is_null($this->container['expression_type']) && !in_array($this->container['expression_type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'expression_type', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        $allowedValues = $this->getServingStatusAllowableValues();
        if (!is_null($this->container['serving_status']) && !in_array($this->container['serving_status'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'serving_status', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets target_id
     *
     * @return float
     */
    public function getTargetId()
    {
        return $this->container['target_id'];
    }

    /**
     * Sets target_id
     *
     * @param float $target_id target_id
     *
     * @return $this
     */
    public function setTargetId($target_id)
    {
        $this->container['target_id'] = $target_id;

        return $this;
    }

    /**
     * Gets ad_group_id
     *
     * @return float
     */
    public function getAdGroupId()
    {
        return $this->container['ad_group_id'];
    }

    /**
     * Sets ad_group_id
     *
     * @param float $ad_group_id ad_group_id
     *
     * @return $this
     */
    public function setAdGroupId($ad_group_id)
    {
        $this->container['ad_group_id'] = $ad_group_id;

        return $this;
    }

    /**
     * Gets campaign_id
     *
     * @return float
     */
    public function getCampaignId()
    {
        return $this->container['campaign_id'];
    }

    /**
     * Sets campaign_id
     *
     * @param float $campaign_id campaign_id
     *
     * @return $this
     */
    public function setCampaignId($campaign_id)
    {
        $this->container['campaign_id'] = $campaign_id;

        return $this;
    }

    /**
     * Gets state
     *
     * @return string
     */
    public function getState()
    {
        return $this->container['state'];
    }

    /**
     * Sets state
     *
     * @param string $state state
     *
     * @return $this
     */
    public function setState($state)
    {
        $allowedValues = $this->getStateAllowableValues();
        if (!is_null($state) && !in_array($state, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'state', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['state'] = $state;

        return $this;
    }

    /**
     * Gets expression_type
     *
     * @return string
     */
    public function getExpressionType()
    {
        return $this->container['expression_type'];
    }

    /**
     * Sets expression_type
     *
     * @param string $expression_type expression_type
     *
     * @return $this
     */
    public function setExpressionType($expression_type)
    {
        $allowedValues = $this->getExpressionTypeAllowableValues();
        if (!is_null($expression_type) && !in_array($expression_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'expression_type', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['expression_type'] = $expression_type;

        return $this;
    }

    /**
     * Gets bid
     *
     * @return float
     */
    public function getBid()
    {
        return $this->container['bid'];
    }

    /**
     * Sets bid
     *
     * @param float $bid If a value for `bid` is specified, it overrides the current adGroup bid. When using vcpm costType. $1 is the minimum bid for vCPM. Note that this field is ignored for negative targeting clauses.
     *
     * @return $this
     */
    public function setBid($bid)
    {
        $this->container['bid'] = $bid;

        return $this;
    }

    /**
     * Gets expression
     *
     * @return \AmazonAdvertisingApi\Model\TargetingExpression
     */
    public function getExpression()
    {
        return $this->container['expression'];
    }

    /**
     * Sets expression
     *
     * @param \AmazonAdvertisingApi\Model\TargetingExpression $expression expression
     *
     * @return $this
     */
    public function setExpression($expression)
    {
        $this->container['expression'] = $expression;

        return $this;
    }

    /**
     * Gets resolved_expression
     *
     * @return \AmazonAdvertisingApi\Model\TargetingExpression
     */
    public function getResolvedExpression()
    {
        return $this->container['resolved_expression'];
    }

    /**
     * Sets resolved_expression
     *
     * @param \AmazonAdvertisingApi\Model\TargetingExpression $resolved_expression resolved_expression
     *
     * @return $this
     */
    public function setResolvedExpression($resolved_expression)
    {
        $this->container['resolved_expression'] = $resolved_expression;

        return $this;
    }

    /**
     * Gets serving_status
     *
     * @return string
     */
    public function getServingStatus()
    {
        return $this->container['serving_status'];
    }

    /**
     * Sets serving_status
     *
     * @param string $serving_status The status of the target.
     *
     * @return $this
     */
    public function setServingStatus($serving_status)
    {
        $allowedValues = $this->getServingStatusAllowableValues();
        if (!is_null($serving_status) && !in_array($serving_status, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'serving_status', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['serving_status'] = $serving_status;

        return $this;
    }

    /**
     * Gets creation_date
     *
     * @return int
     */
    public function getCreationDate()
    {
        return $this->container['creation_date'];
    }

    /**
     * Sets creation_date
     *
     * @param int $creation_date Epoch date the target was created.
     *
     * @return $this
     */
    public function setCreationDate($creation_date)
    {
        $this->container['creation_date'] = $creation_date;

        return $this;
    }

    /**
     * Gets last_updated_date
     *
     * @return int
     */
    public function getLastUpdatedDate()
    {
        return $this->container['last_updated_date'];
    }

    /**
     * Sets last_updated_date
     *
     * @param int $last_updated_date Epoch date of the last update to any property associated with the target.
     *
     * @return $this
     */
    public function setLastUpdatedDate($last_updated_date)
    {
        $this->container['last_updated_date'] = $last_updated_date;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    #[\ReturnTypeWillChange]
    public function offsetExists($offset)
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset)
    {
        return isset($this->container[$offset]) ? $this->container[$offset] : null;
    }

    /**
     * Sets value based on offset.
     *
     * @param integer $offset Offset
     * @param mixed   $value  Value to be set
     *
     * @return void
     */
    #[\ReturnTypeWillChange]
    public function offsetSet($offset, $value)
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer $offset Offset
     *
     * @return void
     */
    #[\ReturnTypeWillChange]
    public function offsetUnset($offset)
    {
        unset($this->container[$offset]);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
            return json_encode(
                ObjectSerializer::sanitizeForSerialization($this),
                JSON_PRETTY_PRINT
            );
        }

        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}
